from django.db import models
from user_app.models import User
from examination_questions_app.models import ExaminationQuestions


class AiConversation(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    title = models.CharField(max_length=255, default="新会话", verbose_name="对话标题")
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        db_table = 't_ai_conversation'

### 会话
class ConversationMessage(models.Model):
    conversation = models.ForeignKey(AiConversation, on_delete=models.CASCADE)
    role = models.CharField(max_length=10, choices=(('user', '用户'), ('assistant', '助手'), ('system', '系统')), default='user')
    content = models.TextField(verbose_name="对话内容")
    created_at = models.DateTimeField(auto_now_add=True)
    class Meta:
        db_table = 't_conversation_message'
